<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Retrieve attribute information</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="hwapi.move.html">hw_api::move</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="hwapi.objectbyanchor.html">hw_api::objectbyanchor</a></div>
 <div class="up"><a href="ref.hwapi.html">Hyperwave API 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="hwapi.object" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hw_api::object</h1>
  <p class="verinfo">(PHP 4, PHP 5 &lt; 5.2.0, PECL hwapi SVN)</p><p class="refpurpose"><span class="refname">hw_api::object</span> &mdash; <span class="dc-title">Retrieve attribute information</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-hwapi.object-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type hw_api_object">hw_api_object</span></span> <span class="methodname"><strong>hw_api::object</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$parameter</code></span>
   )</div>

  <p class="para rdfs-comment">
   This function retrieves the attribute information of an object of any
   version. It will not return the document content. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-hwapi.object-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">parameter</code></em></dt>

     <dd>

      <p class="para">
       The parameter array contains the required elements &#039;objectIdentifier&#039;
       and the optional elements &#039;attributeSelector&#039; and &#039;version&#039;.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-hwapi.object-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The returned object is an instance of class
   <strong class="classname">HW_API_Object</strong> on success or
   <strong class="classname">HW_API_Error</strong> if an error occurred.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-hwapi.object-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   This simple example retrieves an object and checks for errors.
   <div class="example" id="example-4289">
    <p><strong>Example #1 Retrieve an object</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">handle_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$error</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$reason&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$error</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">reason</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Type:&nbsp;&lt;b&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;switch&nbsp;(</span><span style="color: #0000BB">$reason</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">type</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Error"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Warning"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Message"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;/b&gt;&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Description:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$reason</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">description</span><span style="color: #007700">(</span><span style="color: #DD0000">"en"</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />}<br /><br />function&nbsp;</span><span style="color: #0000BB">list_attr</span><span style="color: #007700">(</span><span style="color: #0000BB">$obj</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;table&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$count&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count</span><span style="color: #007700">();<br />&nbsp;&nbsp;for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">&lt;</span><span style="color: #0000BB">$count</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$attr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$i</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"&lt;tr&gt;&lt;td&nbsp;align=\"right\"&nbsp;bgcolor=\"#c0c0c0\"&gt;&lt;b&gt;%s&lt;/b&gt;&lt;/td&gt;&lt;td&nbsp;bgcolor=\"#F0F0F0\"&gt;%s&lt;/td&gt;&lt;/tr&gt;\n"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">key</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">value</span><span style="color: #007700">());<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;/table&gt;\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$hwapi&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">hwapi_hgcsp</span><span style="color: #007700">(</span><span style="color: #0000BB">$g_config</span><span style="color: #007700">[</span><span style="color: #0000BB">HOSTNAME</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$parms&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">"objectIdentifier"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"rootcollection"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"attributeSelector"</span><span style="color: #007700">=&gt;array(</span><span style="color: #DD0000">"Title"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Name"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"DocumentType"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$root&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$hwapi</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">object</span><span style="color: #007700">(</span><span style="color: #0000BB">$parms</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$root</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #DD0000">"HW_API_Error"</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">handle_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$root</span><span style="color: #007700">);<br />&nbsp;&nbsp;exit;<br />}<br /></span><span style="color: #0000BB">list_attr</span><span style="color: #007700">(</span><span style="color: #0000BB">$root</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-hwapi.object-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="hwapi.content.html" class="xref">hw_api::content</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="hwapi.move.html">hw_api::move</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="hwapi.objectbyanchor.html">hw_api::objectbyanchor</a></div>
 <div class="up"><a href="ref.hwapi.html">Hyperwave API 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
